import Vue from 'vue'
import VueRouter from 'vue-router'
import HomeView from '../views/IndexView.vue'
import AdminView from "@/views/admin/AdminView";
import ConsumerView from "@/views/user/consumer/ConsumerView";
import WorkerView from "@/views/user/worker/WorkerView";
import IndexView from "@/views/IndexView";

Vue.use(VueRouter)

const routes = [
    {
        path: '/',
        name: "index",
        component: IndexView,
        redirect: '/index/main', // 重定向
        children: [
            {
                path: '/index/main',
                name: 'main',
                component: () => import( '../views/IndexmainView.vue')
            },
            {
                path: '/index/detail/:id',
                name: 'detail',
                component: () => import( '../views/IndexDetailView.vue')
            },
            {
                path: '/user/login',
                component: () => import('../views/user/UserLoginView.vue')
            },
            {
                path: '/user/register',
                component: () => import('../views/user/UserRegisterView.vue')
            },
            {
                path: '/index/result/:wd',
                name: 'result',
                component: () => import('../views/IndexResult.vue')
            },


        ]
    },
    {
        path: '/admin/login',
        component: () => import( '../views/admin/AdminLoginView.vue')
    },
    {
        path: '/worker/login',
        component: () => import( '../views/user/WorkerLoginView.vue')
    },
    {
        path: '/worker/register',
        component: () => import( '../views/user/WorkerRegisterView.vue')
    },

    {
        path: '/admin',
        component: AdminView,
        redirect: '/admin/index', // 重定向
        children: [
            {
                path: '/admin/index',
                component: () => import('../views/admin/manage/SystemAdminIndex.vue')
            },
            {
                path: '/admin/add-new',
                component: () => import('../views/admin/manage/AdminAddNewView.vue')
            },
            {
                path: '/admin/category/add-new',
                component: () => import('../views/admin/manage/CategoryAddNewView.vue')
            },
            {
                path: '/admin/list',
                component: () => import('../views/admin/manage/AdminListView.vue')
            },
            {
                path: '/admin/category/list',
                component: () => import('../views/admin/manage/CategoryListView.vue')
            },
            {
                path: '/admin/category/item/list',
                component: () => import('../views/admin/manage/CategoryItemList.vue')
            },

            {
                path: '/admin/carousel/list',
                component: () => import('../views/admin/manage/CarouselMap.vue')
            },
            {
                path: '/admin/Review/moderation',
                component: () => import('../views/admin/manage/ReviewModeration.vue')
            },
            {
                path: '/admin/order/list',
                component: () => import('../views/admin/manage/OrderList.vue')
            },
        ]
    },

    {
        path: '/consumer',
        component: ConsumerView,
        redirect: '/consumer/index', // 重定向
        children: [
            {
                path: '/consumer/index',

                component: () => import('../views/user/consumer/manage/ConsumerIndex.vue')
            },
            {
                path: '/consumer/up-phone',
                component: () => import('../views/user/consumer/manage/ConsumerPhoneBindView.vue')
            },
            {
                path: '/consumer/up-address',
                component: () => import('../views/user/consumer/manage/ConsumerUpdateAddressView.vue')
            },
            {
                path: '/consumer/up-password',
                component: () => import('../views/user/consumer/manage/ConsumerUpdatePasswordView.vue')
            },
            {
                path: '/consumer/up-info',
                component: () => import('../views/user/consumer/manage/ConsumerUpdateInfoView.vue')
            },
        ]
    },
    {
        path: '/worker',
        component: WorkerView,
        redirect: '/worker/index', // 重定向
        children: [
            {
                path: '/worker/index',
                component: () => import('../views/user/worker/manage/WorkerIndex.vue')
            },
            {
                path: '/worker/viewOrder',
                component: () => import('../views/user/worker/manage/WorkerViewOrder.vue')
            },
            {
                path: '/worker/addServe',
                component: () => import('../views/user/worker/manage/WorkerAddServe.vue')
            },
        ]
    },
]

const router = new VueRouter({
    mode: 'history',
    base: process.env.BASE_URL,
    routes
})

export default router
